package com.heima.minio.config;

import io.minio.MinioClient;
import io.minio.errors.InvalidEndpointException;
import io.minio.errors.InvalidPortException;
import org.springframework.context.annotation.Bean;

/**
 * @BelongsProject: heima-leadnews
 * @BelongsPackage: com.heima.minio.config
 * @Author: wangjian
 * @CreateTime: 2022-06-30  21:08
 * @Description: TODO
 * @Version: 1.0
 */
public class MinIOConfig {
    @Bean
    public MinioClient minioClient(MinIOProperties minIOProperties) throws InvalidPortException, InvalidEndpointException {
        // 使用MinIO服务的URL，端口，Access key和Secret key创建一个MinioClient对象
        MinioClient minioClient = MinioClient.builder()
                .endpoint(minIOProperties.getEndpoint())
                .credentials(minIOProperties.getAccessKey(),minIOProperties.getSecretKey())
                .build();
        return minioClient;
    }
}
